package com.csust.advanced.pool;

import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.junit.Test;

import java.io.InputStream;
import java.sql.Connection;
import java.util.Properties;

public class HikariTest {
    @Test
    public void test() throws Exception{
        HikariDataSource hds = new HikariDataSource();


        hds.setJdbcUrl("jdbc:mysql://localhost:3306/atguigu?useUnicode=true&useSSL=false");
        hds.setUsername("root");
        hds.setPassword("123456");


        hds.setMinimumIdle(10);
        hds.setMaximumPoolSize(20);


        Connection conn = hds.getConnection();

        System.out.println(conn);


        conn.close();



    }

    @Test
    public void test2() throws Exception{
        Properties props = new Properties();

        InputStream is = HikariTest.class.getClassLoader().getResourceAsStream("hikari.properties");
        props.load(is);

        HikariConfig hc = new HikariConfig(props);


        HikariDataSource hds = new HikariDataSource(hc);


        Connection conn = hds.getConnection();
        System.out.println(conn);

        conn.close();



    }
}
